package server.start;
import java.io.*;
import java.net.*;

public class ServerStart {

	public ServerStart(){
		try{
			ServerSocket serverSocket = new ServerSocket(3123);
			System.out.println("서버 기동...");
			Socket socket = serverSocket.accept();
			System.out.println("클라이어트 소켓 접속..");
			InetAddress ia = socket.getInetAddress();
			String ip = ia.getHostAddress();
			System.out.println("["+ip+"]의 클라이언트가 접속하였습니다");
			InputStream is = socket.getInputStream();
			OutputStream os = socket.getOutputStream();
			BufferedReader br = new BufferedReader(new InputStreamReader(is));
			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
			String messag = br.readLine();
			System.out.println("클라이어트 메시지 : "+messag);
			bw.write("나는 서버입니다\n");
			bw.flush();		
		}catch(IOException ioe){
			System.out.println("포트가 사용중입니다");
			System.out.println(ioe.toString());
		}
	}
	public static void main(String[] art){
		new ServerStart();
	}
}
